/// <summary>
/// Copyright 2010 Ivo Limmen (ivo@limmen.org)
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
/// 
/// http://www.apache.org/licenses/LICENSE-2.0
/// 
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// </summary>

using System;
using System.Diagnostics;

namespace Util.Logging
{
	public class EventLogger
	{
		public EventLogger()
		{
		}

		public static void Information(string source, string message)
		{
			Log(source, message, EventLogEntryType.Information);
		}

		public static void Warning(string source, string message)
		{
			Log(source, message, EventLogEntryType.Warning);
		}

		public static void Error(string source, string message)
		{
			Log(source, message, EventLogEntryType.Error);
		}

		public static void FailureAudit(string source, string message)
		{
			Log(source, message, EventLogEntryType.FailureAudit);
		}

		public static void SuccessAudit(string source, string message)
		{
			Log(source, message, EventLogEntryType.SuccessAudit);
		}

		private static void Log(string source, string message, EventLogEntryType type)
		{
			using (EventLog log = new EventLog())
			{
				log.Source = source;
				log.WriteEntry(message, type);
			}
		}
	}
}
